#!/bin/sh
source ./.phrc
echo "正在安装podHelper..."
script_path=$(cd $(dirname "$0"); pwd)
folder_name=$(basename $script_path)
#  脚本安装
if [ -d ${LOCAL_REP_RELATIVE_HOME_PATH/"~"/$HOME} ]; then
    echo "${LOCAL_REP_RELATIVE_HOME_PATH/"~"/$HOME}文件夹已存在 !"
    cp -r $(dirname "$0")/../$folder_name/ ~/Develop/iOS/.podHelper/
else
    echo "${LOCAL_REP_RELATIVE_HOME_PATH/"~"/$HOME}文件夹不存在 !"
    echo "正在创建${LOCAL_REP_RELATIVE_HOME_PATH/"~"/$HOME}..."
    mkdir ${LOCAL_REP_RELATIVE_HOME_PATH/"~"/$HOME}
    cp -r $(dirname "$0")/../$folder_name/ ~/Develop/iOS/.podHelper/
fi
# 自定义命令
# sudo chmod +w ~/.zshrc
if [ ! -f "~/.zshrc" ]; then
    custom_cmd="alias podLibPublish='ruby ${LOCAL_REP_RELATIVE_HOME_PATH/"~"/$HOME}/.podHelper/podLibPublish.rb'"
    if ! grep -q "podLibPublish" ~/.zshrc; then
        sudo echo $custom_cmd >> ~/.zshrc
    fi
    source ~/.zshrc
    echo "podHper install success ! 🎉🎉🎉 "
else
    echo "~/.zshrc 文件不存在"
    echo "podHper install fail ! 💔💔💔 "
fi


